package com.eschool.beans.converter;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.primefaces.model.DualListModel;


public class PickListBean {

	private DualListModel<Player> players;

	private DualListModel<String> cities;

	public PickListBean() {
		//Players
		List<Player> source = new ArrayList<Player>();
		List<Player> target = new ArrayList<Player>();

        source.add(new Player("Messi", 10, "messi.jpg"));
		source.add(new Player("Iniesta", 8, "iniesta.jpg"));
		source.add(new Player("Villa", 7, "villa.jpg"));
		source.add(new Player("Alves", 2, "alves.jpg"));
		source.add(new Player("Xavi", 6, "xavi.jpg"));
		source.add(new Player("Puyol", 5, "puyol.jpg"));	

		players = new DualListModel<Player>(source, target);

		//Cities
		List<String> citiesSource = new ArrayList<String>();
		List<String> citiesTarget = new ArrayList<String>();

		citiesSource.add("Istanbul");
		citiesSource.add("Ankara");
		citiesSource.add("Izmir");
		citiesSource.add("Antalya");
		citiesSource.add("Bursa");

		cities = new DualListModel<String>(citiesSource, citiesTarget);
	}

	public DualListModel<Player> getPlayers() {
		return players;
	}
	public void setPlayers(DualListModel<Player> players) {
		this.players = players;
	}

	public DualListModel<String> getCities() {
		return cities;
	}
	public void setCities(DualListModel<String> cities) {
		this.cities = cities;
	}
	
	public String performAction(){
		for (Iterator iterator = players.getTarget().iterator(); iterator.hasNext();) {
			Player player = (Player) iterator.next();
			System.out.println(player.getName());
		}
		return "";
	}
	
}
                    